﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace SpeechBill
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == null || textBox2.Text == null)
            {
                label4.Text = "请输入用户名或密码";
                textBox1.Focus();
            }
            else
            {
                string username = textBox1.Text;
                string password = textBox2.Text;
                string sql = "insert into userlogin(username,password) values('"+username+"','"+password+"')";
                int count = DBHelper.ExctInsertDelUp(sql);
                if (count > 0)
                {
                    MessageBox.Show("注册成功，等待返回登录界面");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("注册失败");
                }
                
            }
        }

        private void Register_Load(object sender, EventArgs e)
        {
            label4.Text = null;
        }
    }
}
